home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr49 / 107_01.zip / FIO.2 < prev    next >
Text File  |  1993-06-06  |  2KB  |  66 lines

  1. /*********************************************
  2. *    This source code was contributed by:    *
  3. *                                            *
  4. *         Eric Martz                         *
  5. *         Department of Microbiology         *
  6. *         University of Massachusetts        *
  7. *         Amherst, MA 01003                  *
  8. *                                            *
  9. *    Phones:                                 *
  10. *                                            *
  11. *         Day:      413-545-2325             *
  12. *         Evenings: 413-256-0751             *
  13. *                                            *
  14. *********************************************/
  15.  
  16.  
  17. /* For an example of the use of "fio.2" and an introduction, see "fio.1". */
  18.  
  19. /* "fio.2" SHOULD BE INCLUDED AS THE FIRST EXECUTABLE CODE IN MAIN;
  20.    IT ZEROS ALL bufuse ELEMENTS, INDICATING THAT NO BUFFERS ARE ASSIGNED
  21.    TO FILES INITIALLY. */
  22.  
  23.     for(bufuse[0]=1;bufuse[0]<=NIOBUFS;bufuse[bufuse[0]++]=0);
  24.  
  25.     /* THE NEXT STATEMENT LEAVES bufuse[0] SET AT NIOBUFS FOR
  26.         USE BY FOPEN, FCLOSE */
  27.  
  28.     bufuse[0] -= 1;
  29.  
  30.     /* End of fio.2 *
  31.                                n a "word count" program:
  32.  
  33.     ---------------------------------------------------------
  34.     #include "bdscio.h"
  35.     
  36.     #define NIOBUFS 1
  37.     #include "fio.1"
  38.     
  39.     main(argc,argv)
  40.         int argc;
  41.         char **argv;
  42.         {
  43.     #include "fio.2"
  44.         if (argc == 1) {
  45.             printf("Use: wc filename\n");
  46.             exit(0);
  47.         }
  48.         allcnt(argv[1]);
  49.     }
  50.     allcnt(name)
  51.         char *name;
  52.         {
  53.         unsigned linecnt, charcn/*********************************************
  54. *    This source code was contributed by:    *
  55. *                                            *
  56. *         Eric Martz                         *
  57. *         Department of Microbiology         *
  58. *         University of Massachusetts        *
  59. *         Amherst, MA 01003                  *
  60. *                                            *
  61. *    Phones:                                 *
  62. *                                            *
  63. *         Day:      413-545-2325             *
  64. *         Evenings: 413-256-0751             *
  65. *                                            *
  66. ****************